package xyz.xuminghai.javafx_learn.other;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.BorderPane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Circle;
import javafx.scene.shape.Rectangle;
import javafx.scene.shape.Shape;
import javafx.stage.Stage;

/**
 * 2023/9/22 10:55 星期五<br/>
 *
 * @author xuMingHai
 */
public class ShapeCropApp extends Application {

    private final BorderPane root = new BorderPane();

    public static void main(String[] args) {
        Application.launch(args);
    }

    @Override
    public void init() throws Exception {
        Rectangle rectangle = new Rectangle(300.0, 200.0);
        Circle circle = new Circle((rectangle.getWidth() / 2),
                (rectangle.getHeight() / 2),
                50.0);
        Shape shape = Shape.subtract(rectangle, circle);
        shape.setFill(Color.RED);
        root.setCenter(shape);
    }

    @Override
    public void start(Stage primaryStage) throws Exception {
        primaryStage.setTitle(getClass().getSimpleName());
        Scene scene = new Scene(root, 800, 600);
        primaryStage.setScene(scene);
        primaryStage.show();
    }
}
